<div class="crumb-wrap">
    <div class="crumb-list"><i class="icon-font"></i><a href="<?=site_url('admini')?>">首页</a>
        <span class="crumb-step">&gt;</span><a class="crumb-name" href="<?=site_url('admini/goods')?>">商品管理</a></span>
        <span class="crumb-step">&gt;</span><span>商品图片</span>
    </div>
</div>


<div class="search-wrap">
    <div class="search-content">
        <table class="search-tab" id="goods_menu">
        </table>

        <div class="search-tab layer-photos-demo" id="layer-photos-demo">
        <?php foreach($list as $k => $v): ?>
            <div style="margin: 20px 0px 20px 20px;float: left">
            <img src="<?=$v['path'].$v['thumb']?>" width="150px" height="150px"  layer-pid="<?=$v['id']?>" layer-src="<?=$v['path'].$v['file_name']?>" alt="<?=$v['name']?>">
            <br />
            <a href="javascript:;" onclick="img_delete(<?=$v['id']?>)">删除</a> | 
            <a href="javascript:;" onclick="set_sort(<?=$v['id']?>,<?=$v['sort']?>)">排序<?=$v['sort'] == 0 ? '' : '【'.$v['sort'].'】'?></a>
            </div>
        <?php endforeach;?>
        </div>

        <div class="result-wrap" style="margin-top: 220px">
            <div class="result-content">
                <form action="<?=site_url('admini/image/uploaded')?>" method="post" id="myform" name="myform" enctype="multipart/form-data">
                    <table class="insert-tab" width="100%">
                        <tbody>
                            
                            <tr>
                                <th><i class="require-red">*</i>上传：</th>
                                <td>
                                    <input name="smallimg" id="" type="file">
                                    <span>最多只能上传7张图片</span>
                                </td>
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>备注：</th>
                                <td>
                                    <input class="common-text required" id="title" name="title" size="50" value="" type="text">
                                </td>
                            </tr>
                            <tr>
                                <th></th>
                                <td>
                                    <input type="hidden" name="gid" value="<?=$res['id']?>">
                                    <input class="btn btn-primary btn6 mr10" value="提交" type="submit">
                                    <input class="btn btn6" onclick="history.go(-1)" value="返回" type="button">
                                </td>
                            </tr>
                        </tbody></table>
                </form>
            </div>
        </div>
    </div>
</div>



<script type="text/javascript" charset="utf-8">
//加载菜单
$.get("<?=site_url('admini/widget/goods_menu?menu=6&gid='.$res['id'])?>",function(data){
    $("#goods_menu").html(data);
},'text');

//ajax提交
$('#myform').submit(function() {
    $(this).ajaxSubmit(function(data){
        if(data == 1){
             location.reload();
        }else{
            layer.alert(data,{
                icon:2,
            });
        }
    })
    return false;
})

layer.config({
    extend: 'extend/layer.ext.js'
});    

//相册
layer.ready(function(){ //为了layer.ext.js加载完毕再执行
    layer.photos({
        photos: '#layer-photos-demo'
    });
});

//删除
function img_delete(iid){
    layer.confirm('真的要删除该图片吗？', {
        icon:0,
        btn: ['删除','取消'], //按钮
        shade: false //不显示遮罩
    }, function(){
        $.post("<?=site_url('admini/image/del_image')?>",{iid:iid},function(res){
            if(res == 1){
                location.reload(true);
            }else{
                layer.alert(res,{
                    icon:2,
                });
            }
        })
    });
}

//设置排序
function set_sort(id,val){
    layer.prompt({
        title: '输入数字（值越大越靠前）',
        formType: 0, //prompt风格，支持0-2
        value : val
    }, function(pass){
        $.post("<?=site_url('admini/image/set_sort')?>",{iid:id,val:pass},function(res){
            if(res == 1){
                location.reload(true);
            }else{
                layer.alert(res,{
                    icon:2,
                });
            }
        });
    });
}

</script>